package com.maple.exclusivesport;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.maple.exclusivesport.adapters.ContactInfo;

import org.greenrobot.eventbus.EventBus;

import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by maple on 2019/8/20 14:39
 * E-Mail Address：740917401@qq.com
 */
public class ConfirmDialog extends Dialog {


    Context context;
    String title;
    String content;
    @Bind(R.id.titleTv)
    TextView titleTv;
    @Bind(R.id.contentTv)
    TextView contentTv;

    public interface onConfirmDialogListener {
        public void onConfirm();

        public void onCancel();
    }

    public onConfirmDialogListener listener;

    public ConfirmDialog(@NonNull Context context, String title, String content, onConfirmDialogListener listener) {
        super(context, R.style.CustomDialog);
        this.context = context;
        this.title = title;
        this.content = content;
        this.listener = listener;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View view = View.inflate(getContext(), R.layout.dialog_confirm, null);
        setContentView(view);
        ButterKnife.bind(this, view);
        titleTv.setText(title);
        contentTv.setText(content);

    }


    @OnClick({R.id.okBtn, R.id.cancelBtn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.okBtn:
                if(listener!=null){
                    listener.onConfirm();
                }
                dismiss();
                break;
            case R.id.cancelBtn:
                if(listener!=null){
                    listener.onCancel();
                }
                dismiss();
                break;
        }
    }
}
